{% extends 'base.html' %}
{% block content %}
<div class="container mt-4">
    <h2>{{ building.name }} 详情</h2>
    <div class="card mb-4">
        <div class="card-body">
            <h5 class="card-title">基本信息</h5>
            <p class="card-text">
                <strong>所属工程:</strong> {{ building.project.name }}<br>
                <strong>位置:</strong> {{ building.location }}<br>
                <strong>监测断面:</strong> {{ building.section }}
            </p>
            <a href="{% url 'section-update' building.pk %}" class="btn btn-warning">编辑断面</a>
            <a href="{% url 'sensor-create' building.pk %}" class="btn btn-primary">添加测点</a>
            <a href="{% url 'sensor-export' building.pk %}" class="btn btn-success">导出测点数据</a>
            <a href="{% url 'sensor-import' building.pk %}" class="btn btn-info">导入测点数据</a>
        </div>
    </div>

    <h4>测点列表</h4>
    <table class="table table-striped">
        <thead>
            <tr>
                <th>名称</th>
                <th>类型</th>
                <th>位置</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {% for sensor in building.sensor_set.all %}
            <tr>
                <td>{{ sensor.name }}</td>
                <td>{{ sensor.sensor_type }}</td>
                <td>{{ sensor.location }}</td>
                <td>{{ sensor.get_status_display }}</td>
                <td>
                    <a href="{% url 'sensor-detail' sensor.pk %}" class="btn btn-sm btn-info">查看</a>
                    <a href="{% url 'sensor-update' sensor.pk %}" class="btn btn-sm btn-warning">编辑</a>
                    <a href="{% url 'sensor-delete' sensor.pk %}" class="btn btn-sm btn-danger">删除</a>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
{% endblock %}